<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
</body>
</html>
<script>
var students = [
  {age: 19},
  {age: 19},
  {age: 22},
];

/* for ... in 
  案例：判断学生们 是否 都成年了；若都成年了，alert('都成年了')   
  否则，alter('有没成年的')

  // 方法1 ： for in 循环 判断  有没 未成年的
  var isAllAdult = true;
  for (var key in students) {
    var student = students[key];
    if (student.age < 18) {
      isAllAdult = false;
    }
  }
  alert(isAllAdult ? '都成年了' : '有没成年的');
*/

var isAllAdult = students.every(function(item) {
  return item.age >= 18;
});
alert(isAllAdult ? '都成年了' : '有没成年的');
</script>